package com.project.service.impl;

import java.util.List;

import com.project.entity.GeneralManager;
import com.project.entity.GeneralManagerExample;
import com.project.mapper.GeneralManagerMapper;
import com.project.service.GeneralManagerManage;

public class GeneralManagerManageService implements GeneralManagerManage {
	private GeneralManagerMapper generalManagerMapper;
	
	

	public GeneralManagerMapper getGeneralManagerMapper() {
		return generalManagerMapper;
	}

	public void setGeneralManagerMapper(GeneralManagerMapper generalManagerMapper) {
		this.generalManagerMapper = generalManagerMapper;
	}

	public void deleteById(Integer generalManagerId) {
		this.generalManagerMapper.deleteByPrimaryKey(generalManagerId);

	}

	public List<GeneralManager> getAllGeneralManager(Integer start,Integer limit) {		
		return this.generalManagerMapper.getAllGeneralManager(start, limit);
	}

	public GeneralManager getById(Integer generalManagerId) {
		return this.generalManagerMapper.selectByPrimaryKey(generalManagerId);
	}

	public int insertGeneralManager(GeneralManager generalManager) {
		int i;
		try{
			this.generalManagerMapper.insert(generalManager);
			i = 1;
		}catch(Exception e){
			i = -1;
			e.printStackTrace();
		}
		return i;
	}
	

	/**
	 * 修改普通管理员的信息
	 */
	public int update(GeneralManager generalManager) {
		int i;
		try{
			this.generalManagerMapper.updateManager(generalManager);
			i = 1;
		}catch(Exception e){
			i = -1;
			e.printStackTrace();
		}
		return i;
	}

	public Integer countAllGeneralManager(){
		GeneralManagerExample example = new GeneralManagerExample();
		return this.generalManagerMapper.countByExample(example);
	}

	/**
	 * 修改密码
	 */
	public int changePass(String past, String pass1, String id) {
		// TODO Auto-generated method stub
		int i;
		try{
			i = this.generalManagerMapper.changePass(past, pass1, id);
		}catch(Exception e){
			i= -1;
			e.printStackTrace();
		}
		return i;
	}

	public GeneralManager getByNumber(String number) {
		// TODO Auto-generated method stub
		GeneralManager manager;
		try{
			manager = this.generalManagerMapper.getByNumber(number);
		}catch(Exception e){
			manager = null;
		}
		return manager;
	}
}
